package org.iabako.server.tools;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpSession;
import java.io.File;

/**
 * Created by jose on 05/02/15.
 */
public class FileTools {

    public static String addFileToSession(File tmpFile, String fileName) {

        HttpSession session = (((ServletRequestAttributes) RequestContextHolder.
                currentRequestAttributes()).getRequest()).getSession();

        session.setAttribute(tmpFile.getName(), tmpFile.getAbsolutePath());
        session.setAttribute(tmpFile.getName() + "_fileTitle", fileName);

        return tmpFile.getName();
    }
}
